package com.mhz.mvc.fc;

import java.util.LinkedList;

import ognl.Ognl;
import ognl.OgnlContext;
import ognl.OgnlRuntime;

public class ValueStack {
	private LinkedList<Object> root = new LinkedList<Object>();

	private OgnlContext context = new OgnlContext();

	public void push(Object obj) {
		root.push(obj);
	}

	public Object findValue(String ognl) {
		try {
			Object obj = root.peek(); 
			Object value = Ognl.getValue(ognl, obj);
			return value;
		} catch (Exception e) {
			return null;
		}
	}

	public void setValue(String ognl, Object value) {
		try {
			Object obj = root.peek();
			Ognl.setValue(ognl, context, obj, value);
			System.out.println(Ognl.getValue(ognl, obj));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
